DIRS := $(shell find . -maxdepth 3 -type d)
FILES = $(foreach dir,$(DIRS),$(wildcard $(dir)/*.c))

OBJS := $(FILES:.c=.o)
LIB := libSonixCamera.a


all: $(OBJS) $(LIB)

$(LIB):$(OBJS)
	ar rcs ../SonixCameraDemo/libSonixCamera.a $(wildcard ./output/*.o)
#./output/core.o ./output/descriptor.o ./output/LUOptDev.o ./output/io.o ./output/linux_usbfs.o ./output/SonixCamera.o ./output/sync.o ./output/threads_posix.o ./output/ROMData.o ./output/sfDate.o ./output/v4l2uvc.o ./output/V4L2OptDev.o
#$(wildcard ./output/*.o)
$(OBJS): %.o: %.c
	gcc -g -c -I./libusb -lrt  $< -o $@ 
	mv $@ ./output

clean:
	rm ./output/*.o

